package com.sms.dao.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.sms.dao.ISingleSmsDAO;
import com.sms.po.TWaitsend;

/**
 * @author 20120101 by cxh
 */
public class SingleSmsDAO extends HibernateDaoSupport implements ISingleSmsDAO {
	private static final Log log = LogFactory.getLog(SingleSmsDAO.class);

	@Override
	public List<TWaitsend> showAllSendmsg() {
		log.debug("finding all TWaitsend instances");
		try{
			return super.getHibernateTemplate().find("from TWaitsend");
		}catch(RuntimeException e){
			log.debug("finding all failed:",e);
			throw e;
		}
	}

	@Override
	public List<TWaitsend> showAllSendmsgByPage(DetachedCriteria criteria, int start,int limit) {
		log.debug("finding all TWaitsend by pages");
		try{
			return super.getHibernateTemplate().findByCriteria(
					criteria, start, limit);
		}catch(RuntimeException e){
			log.debug("finding all TWaitsend failed:",e);
			throw e;
		}
	}

	@Override
	public int getAllSendmsgCount(DetachedCriteria criteria) {
		return super.getHibernateTemplate().findByCriteria(criteria).size();
	}

	@Override
	public boolean addSendmsg(TWaitsend ts) {
		log.debug("add TWaitsend instance...");
		try{
			log.debug("add TWaitsend instance success");
			this.getHibernateTemplate().save(ts);
			return true;
		}catch(RuntimeException e){
			log.debug("add TWaitsend instance failed:",e);
			throw e;
		}
	}


}
